﻿// ReSharper disable InconsistentNaming

using System;
using System.Collections.Generic;
using System.Windows.Media;
using Common;
using ImageProcessing.Common;
using ImageProcessing.Engine;
using NUnit.Framework;

namespace ImageProcessing.Tests.Engine
{
    [TestFixture]
    public class OnlineImageProcessingEngineTests
    {
        private OnlineImageProcessingEngine _onlineImageProcessingEngine;

        [Test]
        [TestCase(CameraMode.argb)]
        [TestCase(CameraMode.y)]
        public void LearnImage_ImageLearnt(CameraMode cameraMode)
        {
            _onlineImageProcessingEngine = new OnlineImageProcessingEngine();

            const string learnFileName = "TestPics\\usb2.jpg";
            const string learnName = "testPic";
            TagInfo tagInfo = new TagInfo(Guid.NewGuid(), learnName);
            int width;
            int height;
            HelperMethods.GetImageDimensions(learnFileName, out width, out height);

            List<InterestPoint> pointsLearnt = null;
            int[] argbLoaded = null;
            byte[] ydata = null;


            switch (cameraMode)
            {
                case CameraMode.argb:
                    argbLoaded = HelperMethods.LoadARGBImage(learnFileName, PixelFormats.Pbgra32, width, height);

                    break;

                case CameraMode.y:
                    ydata = HelperMethods.LoadYImage(learnFileName, width, height).rawImage;
                    break;

            }

            pointsLearnt = _onlineImageProcessingEngine.LearnImage(tagInfo, width, height, ref argbLoaded, ref ydata);

            PointsResultProcessor prp = _onlineImageProcessingEngine.MatchPoints(pointsLearnt);

            Assert.AreEqual(tagInfo, prp.BestFoundObject.TagInfo);
        }
    }
}
